package com.cube.backribs.common;

import com.cube.backribs.activity.LoginActivity;
import com.cube.backribs.R;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class AlertDialogFragment extends DialogFragment {
    private int mDialogID;

    public AlertDialogFragment(int id) {
        this.mDialogID = id;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

        switch (mDialogID) {
            case CommonValues.DIALOG_ID_VIEW_NOTICE_REQUEST_LOGIN:
                builder.setTitle(R.string.request_login)
                        .setIcon(R.drawable.ic_warning)
                        .setMessage(R.string.view_notice_request_login)
                        .setPositiveButton(R.string.ok,
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog,
                                            int which) {
                                        ((LoginActivity)getActivity()).doPositiveClick();
                                        dialog.dismiss();
                                    }
                                });
                break;
            default:
                break;
        }

        return builder.create();
    }

}
